package cn.sdormitory.controller.workflow;

import cn.sdormitory.common.api.CommonPage;
import cn.sdormitory.common.api.CommonResult;
import cn.sdormitory.common.exception.ApiException;
import cn.sdormitory.workflow.entity.HygieneRectificationApply;
import cn.sdormitory.workflow.service.HygieneRectificationApplyService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: lx
 * @date: 2023/10/11 9:43
 * @description:
 */
@RestController
@RequestMapping("/hygieneRectification")
@Slf4j
public class HygieneRectificationApplyController {

    @Autowired
    HygieneRectificationApplyService rectificationApplyService;

    /**
     * 提交流程
     * @param vo
     * @return
     * @throws ApiException
     */
    @PostMapping("/createApply")
    public CommonResult<Integer> createApply(@RequestBody HygieneRectificationApply vo){
        int apply = rectificationApplyService.createApply(vo);
        if(apply>0){
            return CommonResult.success();
        }
        if(apply==-1){
            return CommonResult.failed("学生ID为空");
        }
        if(apply==-2){
            return CommonResult.failed("当天已经提交过处理申请");
        }
        return CommonResult.failed();
    }

}
